home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
050
/
bix03.arc
/
METER.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1986-08-04
|
5KB
|
106 lines
{*************************************************************************}
{ }
{ METER }
{ Copyright by Ron Sparks - Not for Sale without Written Permission }
{ Personal use is approved without permission if the }
{ author's name is included }
{ }
{ First version - April 12, 1986 }
{ }
{ Revision History: }
{ }
{ Date Modification }
{ ====== =============================== }
{ }
{ }
{ }
{ }
{ GENERAL COMMENTS }
{ ---------------- }
{ This routine draws a meter for monitoring the progress of any }
{ process. It uses standard IBM compatible graphics characters }
{ and is "well behaved" and a little slow. It autoscales the tic }
{ marks. If first is True then the entire meter is drawn otherwise }
{ only the center bar is updated. X and Y are the coordinates of the }
{ top left corner of the meter and Lngth is the length (characters) }
{ of the meter. The minimum length is 9 and this gives only two }
{ characters to the indicator. The input is in percent and is a }
{ real number. Only whole percents are shown in the digital readout }
{ }
{*************************************************************************}
{----------------------------------------------------------------> METER }
PROCEDURE Meter(VAR x, y, Lngth : Integer; VAR pct : Real;
VAR first : Boolean);
CONST
tl = $C9;
bl = $C8;
tr : STRING[6] = '';
br : STRING[6] = '';
dv = $BA;
sv = $B3;
tic = $D1;
toc = $CF;
maxwid : Integer = 80;
maxht : Integer = 25;
VAR
size, indx, test, markr : Integer;
step, here, next : Real;
line1, line2, line3 : STRING[73];
BEGIN
tr := Chr($D1)+Chr($CD)+Chr($CD)+Chr($CD)+Chr($CD)+Chr($BB);
br := Chr($CF)+Chr($CD)+Chr($CD)+Chr($CD)+Chr($CD)+Chr($BC);
line1 := '';
line2 := '';
line3 := '';
IF (NOT(((x+Lngth) > maxwid) OR ((y+3) > maxht) OR (Lngth < 9))) THEN
BEGIN
IF pct < 0 THEN pct := 0;
IF pct > 100 THEN pct := 100;
size := Lngth-7;
step := 100.0/size;
FOR indx := 1 TO size DO
BEGIN
IF ((indx*step) <= pct) THEN
line2[indx] := Chr($DB)
ELSE
line2[indx] := Chr($20);
line2[0] := Chr(Ord(line2[0])+1);
END;
GoToXY(x, y+1);
Write(Chr(dv), line2, Chr(sv), pct:3:0, '%', Chr(dv));
IF first THEN
BEGIN
test := Round(1.5*step);
markr := 100;
IF test <= 10 THEN markr := 10;
IF (10 < test) AND (test <= 25) THEN markr := 25;
IF (test > 25) AND (test <= 50) THEN markr := 50;
FOR indx := 1 TO size DO
BEGIN
here := indx*step;
next := (indx+1)*step;
IF ((Trunc(next/markr)-Trunc(here/markr)) = 1) THEN
BEGIN
line1[indx] := Chr(tic);
line3[indx] := Chr(toc);
END
ELSE
BEGIN
line1[indx] := Chr($CD);
line3[indx] := Chr($CD);
END;
line1[0] := Chr(Ord(line1[0])+1);
line3[0] := Chr(Ord(line3[0])+1);
END;
GoToXY(x, y);
Write(Chr(tl), line1, tr);
GoToXY(x, y+2);
Write(Chr(bl), line3, br);
END;
END;
END;
{-------------------------------------------------------------< Meter }